//
//  MainTabBarController.swift
//  SinaWeibo
//
//  Created by rk on 15/10/6.
//  Copyright © 2015年 kyy. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {

    @IBOutlet weak var mainTabBar: MainTabBar!

    override func viewDidLoad() {
        super.viewDidLoad()
        addChildViewControllers()
        mainTabBar.composeButton.addTarget(self, action: "composeDidClick", forControlEvents: UIControlEvents.TouchUpInside)
       
    }
    
    func composeDidClick(){
    print(" 点击➕按钮 ")
    
    }
    
    //添加所有的自视图控制器
    private func addChildViewControllers() {
    
//        self.tabBar.tintColor = UIColor.orangeColor()
        
        addChildViewController("Home","首页","tabbar_home")
        addChildViewController("Message","消息","tabbar_message_center")
        addChildViewController("Discover","发现","tabbar_discover")
        addChildViewController("Profile","我","tabbar_profile")
        
    
    }
    
    //添加单视图控制器
    private func addChildViewController(sbName:String, _ title: String, _ imageName: String) {
        
        let sb = UIStoryboard(name: sbName, bundle: nil)
        
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        
        nav.topViewController?.title = title
        
        nav.tabBarItem.image = UIImage(named: imageName)
//        nav.tabBarItem.selectedImage = UIImage (named: imageName + "_highlighted")
        addChildViewController(nav)
        
    }
    
  

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
